package Java攻略._3_流式操作._5_利用peek方法对流进行调试;

import java.util.stream.IntStream;

public class _32_对整数进行倍增_筛选与求和 {

    public static void main(String[] args) {

        _32_对整数进行倍增_筛选与求和 _32 = new _32_对整数进行倍增_筛选与求和();
        int sum = _32.sumDoubleDivisibleBy3(1,6);
        System.out.println(sum);
        // 1,2,3,4,5,6
        // 2,4,6,8,10,12
    }

    public int sumDoubleDivisibleBy3(int start, int end){
        return IntStream.rangeClosed(start,end)
                .map(n -> n *2)
                .filter(n -> n % 3 == 0)
                .sum();
    }
}
